package com.yj.suncity.activity.shouye;

import com.yj.suncity.R;
import com.yj.suncity.constant.ShareCon;
import com.yj.suncity.user.LoginActivity;
import com.yj.suncity.utis.SharedPreferencesUtil;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

public class MyYinkuActivity extends Activity {
	private Context context;
	private ImageView mImg_sign_head;
	private int mWidth;
	private String userId;
	private boolean isLogin;
	private boolean isShop;
	private SharedPreferencesUtil preferencesUtil = SharedPreferencesUtil
			.getInstance();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_yinku);
		context = this;
		mWidth = getResources().getDisplayMetrics().widthPixels;
		mImg_sign_head = (ImageView) findViewById(R.id.img_sign_head);
		mImg_sign_head.setLayoutParams(new RelativeLayout.LayoutParams(mWidth,
				mWidth / 2));

	}

	@Override
	protected void onResume() {
		isLogin = preferencesUtil.getBoolean(context, ShareCon.USERFILE,
				ShareCon.ISLOGIN, false);
		if (isLogin) {
			userId = preferencesUtil.getString(context, ShareCon.USERFILE,
					ShareCon.USERID, "");
			isShop = preferencesUtil.getBoolean(context, ShareCon.USERFILE,
					ShareCon.USERTYPE, false);
		}
		super.onResume();
	}

	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btnHeadBack:
			this.finish();
			break;
		case R.id.img_1_1:// 我的银库
			if (isLogin) {
				Intent intent=new Intent(this, MyYinkuNumActivity.class);
				intent.putExtra("isshop", isShop);
				intent.putExtra("userid", userId);
				startActivity(intent);
			} else {
				startActivity(new Intent(this, LoginActivity.class));
			}
			break;
		case R.id.img_1_2:// 我的礼包
			if (isLogin) {
				Intent intent=new Intent(this, MyLibaoActivity.class);
				intent.putExtra("isshop", isShop);
				intent.putExtra("userid", userId);
				startActivity(intent);
			} else {
				startActivity(new Intent(this, LoginActivity.class));
			}
			break;
		case R.id.img_1_3:// 我的账户
			if (isLogin) {
				Intent intent=new Intent(this, MyZhanghuActivity.class);
				intent.putExtra("isshop", isShop);
				intent.putExtra("userid", userId);
				startActivity(intent);
			} else {
				startActivity(new Intent(this, LoginActivity.class));
			}
			break;
		default:
			break;
		}
	}

}
